package ast;

import src.NFA;
import src.State;

public class ConcatNode extends ASTNode {

	public ConcatNode(ASTNode leftChild, ASTNode rightChild) {
		this.leftChild = leftChild;
		this.rightChild = rightChild;
		this.value = leftChild.getValue() + rightChild.getValue();
	}
	@Override
	public NFA generateNFA() {
		State start = new State(false);
		State accepting = new State(true);
		NFA nfaLeft= leftChild.generateNFA();
		NFA nfaRight= rightChild.generateNFA();
		start.addEpsilonTransition(nfaLeft.getStart());
		nfaLeft.getAccept().addEpsilonTransition(nfaRight.getStart());
		nfaRight.getAccept().addEpsilonTransition(accepting);
		NFA nfa = new NFA(start,accepting); // Create a NFA
		return nfa;
	}

}
